import Vue from 'vue';
import Vuex from 'vuex';


Vue.use (Vuex);


const state = {
  fetchLoading: 'false',// 请求数据时加载状态loading
  fetchmodalType: "",//弹窗类型
  fetchModal: 'false',//弹窗是否显示
  clickOK: 0,//点击了确定
  leadsShow: false,//新增Leads弹窗是否显示
  current_main_menu_condition: '',//一级菜单查询状态
  current_sub_menu_condition: '',//二级菜单查询状态
};

const getters = {
  // 请求数据时加载状态
  fetchLoading: state => state.fetchLoading,
  fetchmodalType: state => state.fetchmodalType,
  fetchModal: state => state.fetchModal,
  clickOK: state => state.clickOK,
  leadsShow: state => state.leadsShow,
};


const actions = {
  // 请求数据时状态loading
  fetch_Loading ({commit}, res) {
    commit ('FETCH_LOADING', res);
  },
};

const mutations = {//Vue 建议mutation 类型用大写常量表示
  // 请求数据时loading
  FETCH_LOADING (state, res) {
    state.fetchLoading = res;
  },
  FETCH_MODALTYPE (state, res) {
    state.fetchmodalType = res;
  },
  FETCH_MODAL (state, res) {
    state.fetchModal = res;
  },
  CLICK_OK (state, res) {
    state.clickOK = res;
  },
  LEADS_SHOW (state, res) {
    state.leadsShow = res;
  },
  SET_MENUONE (state, res) {
    state.current_main_menu_condition = res;
  },
  SET_MENUTWO (state, res) {
    state.current_sub_menu_condition = res;
  },
};
export default new Vuex.Store ({
  state, getters, mutations, actions
})
